<?php  //删除淘宝缓存
$isadmin=1;
include_once 'check.php';
define('STIME',time());

function alert_info($msg1, $meta = '', $jump = '') {
	$title = '系统提示';
	if($jump==-1){$jump='history.go(-1);';}
	$msginfo = "<html>\n<head>
		<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />\r\n" . $meta . "
		<title>" . $title . "</title>
		<base target='_self'/>\n
		<script>setTimeout(function(){".$jump."},1000);</script>
		</head>\n<body style='text-align:center'>\n
		<br/>
		<div style='width:400px;padding-top:4px;height:24;font-size:10pt;border-left:1px solid #cccccc;border-top:1px solid #cccccc;border-right:1px solid #cccccc;background-color:#DBEEBD; text-align:center'>" . $title . "</div>
		<div style='width:400px;height:100px;font-size:10pt;border:1px solid #cccccc;background-color:#F4FAEB; text-align:center'>
		<span style='line-height:160%'><br/>{$msg1}</span></div>";
	echo $msginfo . "\n</body>\n</html>";
}

function del_cache($dir) {
	$dh = opendir($dir);
	while ($file = readdir($dh)) {
		if ($file != "." && $file != "..") {
			$fullpath = $dir . "/" . $file;
			if (!is_dir($fullpath)) {
				if(time()-STIME>1){
					echo "<script>window.location='doclear.php'</script>";
					exit;
				}
				unlink($fullpath);
			} else {
				del_cache($fullpath);
			}
		}
	}
	closedir($dh);
	if (rmdir($dir)) {
		return true;
	} else {
		return false;
	}
}

if(is_dir(DDROOTPATH."/data/Apicache")){
	alert_info('删除淘宝api缓存中。。。<br/><br/><img src="images/wait2.gif" />');
    del_cache(DDROOTPATH."/data/Apicache");
	if(!is_dir(DDROOTPATH."/data/Apicache")){
		echo "<META http-equiv=Content-Type content=\"text/html; charset=utf-8\"><script language=javascript>alert('恭喜您，所有缓存清理完毕！');window.location='temp.php'</script>";
	}
}
else{
    echo "<META http-equiv=Content-Type content=\"text/html; charset=utf-8\"><script language=javascript>alert('恭喜您，所有缓存清理完毕！');window.location='temp.php'</script>";
}
?>